<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2022/9/5
  Time: 14:25
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>添加电影信息</title>
    <script src="statics/layui.js"></script>
    <link rel="stylesheet" href="statics/css/layui.css"/>
    <script src="statics/jquery-1.6.2.min.js"></script>
</head>
<style>
    form {
        width: 500px;
        margin: 0px auto;
    }

    form h1 {
        margin-left: 120px;
    }
</style>
<body>

<form action="add" method="post" class="layui-form-item">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>添加电影信息</legend>
    </fieldset>
    <table border="1" class="layui-table">
        <tr>
            <td>电影名称:</td>
            <td><input type="text" name="movieName" required class="layui-input" onblur="selectByName(this.value)"><span id="title"></span></td>
        </tr>
        <tr>
            <td>电影类型:</td>
            <td><input type="text" name="movieType" required class="layui-input"></td>
        </tr>
        <tr>
            <td>电影价格:</td>
            <td><input type="text" name="price" required class="layui-input"></td>
        </tr>
        <tr>
            <td>是否推荐:</td>
            <td>
                <div class="layui-form">
                    <input type="radio" name="recommend" value="1" title="推荐" checked><div class="layui-unselect layui-form-radio"><i class="layui-anim layui-icon"></i></div>
                    <input type="radio" name="recommend" value="0" title="不推荐"><div class="layui-unselect layui-form-radio layui-form-radioed"><i class="layui-anim layui-icon layui-anim-scaleSpring"></i></div>
                </div>

            </td>
        </tr>
        <tr>
            <td>上映时间:</td>
            <td><input type="text" name="startTime" required class="layui-input">格式:yyyy-MM-dd</td>
        </tr>
        <tr>
            <td>下映时间:</td>
            <td><input type="text" name="endTime" required class="layui-input">格式:yyyy-MM-dd</td>
        </tr>
        <tr>
            <td>投票数:</td>
            <td><input type="text" name="votes" required class="layui-input"></td>
        </tr>
        <tr>
            <td>操作:</td>
            <td>
                <input type="submit" value="添加" class="layui-btn layui-btn-normal">
                <input type="button" name="" value="返回" onclick="javascript:history.back()"
                       class="layui-btn layui-btn-primary">
            </td>
        </tr>
    </table>
</form>
</body>
<script>
    function selectByName(name) {
        $.ajax({
            url:"selectByName",
            data:"name="+name,
            type:"get",
            dataType:"text",
            success:function (data) {
                if (data=="true"){
                    $("#title").html("此名称已存在");
                }else {
                    $("#title").html("");
                }
            }
        })
    }
</script>
</html>

